package algorithm.greedy.p455;

import java.util.Arrays;

/**
 * 455. 分发饼干
 */
class Solution {
    public int findContentChildren(int[] g, int[] s) {
        Arrays.sort(g);
        Arrays.sort(s);
        int res = 0, si = 0, gi = 0;
        while (gi < g.length && si < s.length) {
            if (g[gi] <= s[si]) {
                res++;
                gi++;
            }
            si++;
        }
        return res;
    }

    public static void main(String[] args) {
        System.out.println(new Solution().findContentChildren(new int[]{1, 2}, new int[]{1, 2, 3}));
        System.out.println(new Solution().findContentChildren(new int[]{1, 2, 3}, new int[]{1, 1}));
    }
}